package generic.gui.util;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;

@SuppressWarnings("serial")
public class DefaultFormatterFactoryMask extends DefaultFormatterFactory {
	
	public DefaultFormatterFactoryMask(String mask, Comparable<?> min, Comparable<?> max) {
		DecimalFormat dFormat = new DecimalFormat (mask) ;
		NumberFormatter nf = new NumberFormatter(dFormat);
		nf.setAllowsInvalid(false);
		nf.setMinimum(min);
		nf.setMaximum(max);
		setDefaultFormatter(nf);
	}
	public DefaultFormatterFactoryMask(String mask) {
		DecimalFormat dFormat = new DecimalFormat (mask) ;
		NumberFormatter nf = new NumberFormatter(dFormat);
		nf.setAllowsInvalid(false);
		setDefaultFormatter(nf);
	}
	public DefaultFormatterFactoryMask(NumberFormat formatter, Double min,
			Double max) {
		NumberFormatter nf = new NumberFormatter(formatter);
		nf.setAllowsInvalid(false);
		nf.setMinimum(min);
		nf.setMaximum(max);
		setDefaultFormatter(nf);
	}
}
